package com.qfmy.webapp.service.impl.common;

import com.qfmy.model.entity.common.AppUpdate;
import com.qfmy.model.vo.common.AppUpdateVo;
import com.qfmy.webapp.mapper.common.AppUpdateMapper;
import com.qfmy.webapp.service.common.AppUpdateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 清风明月
 * @Package com.qfmy.webapp.service.impl.common
 * @date 2025/11/24
 * @description app升级中心
 */
@Service
@SuppressWarnings("all")
public class AppUpdateServiceImpl implements AppUpdateService {

    /**
     * 注入mapper
     */
    @Autowired
    private AppUpdateMapper appUpdateMapper;

    /**
     * 获取最新版本
     * @return
     */
    @Override
    public AppUpdateVo getLatestVersion() {
        //获取最新的版本
        AppUpdate appUpdate = appUpdateMapper.getLatestVersion();
        //判断是否为空
        if (appUpdate == null) {
            return null;
        }
        //创建vo对象
        AppUpdateVo appUpdateVo =  new AppUpdateVo();
        appUpdateVo.setVersion(appUpdate.getVersion());
        String[] updateDesc = appUpdate.getUpdateDesc().split(",");
        appUpdateVo.setUpdateDesc(updateDesc);
        appUpdateVo.setOuterLink(appUpdate.getOuterLink());
        return appUpdateVo;
    }
}
